<template>
    <el-card>
        <div class="flex ">
            <el-form :inline="true">
                <el-form-item>
                    <el-input v-model="query.keywords" placeholder="姓名/手机号码/关键字" :clearable="true"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button icon="el-icon-search" type="primary" @click="search">搜索</el-button>
                </el-form-item>
            </el-form>
            <div class="form-filter ml-20"><el-button type="primary" @click="add">添加</el-button></div>
        </div>

        <r-table :data="tableData" :columns="columns">
            <template slot="actions">
                <el-button type="text">查看</el-button>
            </template>
        </r-table>
    </el-card>
</template>

<script>
    import Vue from 'vue'
    import { getMembers } from '@/api/member'
    import Add from './components/Add'

    Vue.component('add-member', Add)

    export default {
        name: 'member',
        data () {
            return {
                query: {
                    keywords: ''
                },
                columns: [
                    { label: '编号', value: 'code' },
                    { label: '姓名', value: 'real_name' },
                    { label: '电话', value: 'phone' },
                    { label: '余额', value: 'money' },
                    { label: '积分', value: 'score' },
                    { label: '家庭住址', value: 'address' },
                    { label: '创建时间', value: 'create_time' },
                    { label: '操作', scope: 'actions' }
                ],
                tableData: [
                    {
                        code: 1001,
                        real_name: 'rjf',
                        money: 1.00,
                        score: 20,
                        phone: 13658295454,
                        address: '重庆市渝北区红旗河沟',
                        create_time: '2018-10-12',
                    },
                    {
                        code: 1001,
                        real_name: 'rjf',
                        money: 1.00,
                        score: 20,
                        phone: 13658295454,
                        address: '重庆市渝北区红旗河沟',
                        create_time: '2018-10-12',
                    },
                    {
                        code: 1001,
                        real_name: 'rjf',
                        money: 1.00,
                        score: 20,
                        phone: 13658295454,
                        address: '重庆市渝北区红旗河沟',
                        create_time: '2018-10-12',
                    },
                    {
                        code: 1001,
                        real_name: 'rjf',
                        money: 1.00,
                        score: 20,
                        phone: 13658295454,
                        address: '重庆市渝北区红旗河沟',
                        create_time: '2018-10-12',
                    },
                    {
                        code: 1001,
                        real_name: 'rjf',
                        money: 1.00,
                        score: 20,
                        phone: 13658295454,
                        address: '重庆市渝北区红旗河沟',
                        create_time: '2018-10-12',
                    }
                ]
            }
        },
        methods: {
            loadData () {
                getMembers().then(res => {
                    console.log(res)
                    this.tableData = res.data;
                })
            },
            search () {

            },
            add () {
                this.$modal('add-member', '添加会员')
            }
        },
        created () {

        }
    }
</script>